package com.example.wechat;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.wechat.model.Contact;

public class ContactDetailActivity extends AppCompatActivity {
    public static final String EXTRA_CONTACT = "extra_contact";

    private ImageView avatarImageView;
    private TextView nameTextView;
    private TextView remarkTextView;
    private TextView phoneTextView;
    private TextView emailTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_contact_detail);

        initViews();
        loadContactData();
    }

    private void initViews() {
        avatarImageView = findViewById(R.id.avatarImageView);
        nameTextView = findViewById(R.id.nameTextView);
        remarkTextView = findViewById(R.id.remarkTextView);
        // phoneTextView = findViewById(R.id.phone_text);
        // emailTextView = findViewById(R.id.email_text);
    }

    private void loadContactData() {
        Contact contact = getIntent().getParcelableExtra(EXTRA_CONTACT);
        if (contact != null) {
            nameTextView.setText(contact.getName());
            remarkTextView.setText(contact.getRemark());
            // 加载头像
            ImageLoader.loadCircleImage(this, contact.getAvatarUrl(), avatarImageView);
        }
    }
}
